package com.lzw.bluetoothpractice.Adapters;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;

public class TableFragmentPagerAdapter extends FragmentPagerAdapter {

    ArrayList<Fragment> lists;
    ArrayList<String> tabs;

    public TableFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setData(ArrayList<Fragment> lists) {
        this.lists = lists;
    }


    public void setTabs(ArrayList<String> tabs) {
        this.tabs = tabs;
    }

    @Override
    public int getCount() {
        return tabs == null ? 0 : tabs.size();
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return lists == null ? null : lists.get(position);
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return tabs == null ? null : tabs.get(position);
    }
}
